package cn.xcyy.itcc.feginfallback;

import cn.xcyy.itcc.enums.GlodalErrorCode;
import cn.xcyy.itcc.fegin.CourseFeignClient;
import cn.xcyy.itcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseFeignClientFallbackFactory implements FallbackFactory<CourseFeignClient> {
    @Override
    public CourseFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new CourseFeignClient() {
            @Override
            public JSONResult courseOrderInfo(String courseIds) {
                return JSONResult.error(GlodalErrorCode.SERVICE_ERROR);
            }

            @Override
            public JSONResult get(Long id) {
                return JSONResult.error(GlodalErrorCode.SERVICE_ERROR);
            }
        };
    }
}
